package redis

import "time"

func (r *Redis) Get(key string) (string, error) {
	res, err := r.conn.Do("get", key)
	if err != nil {
		return "", err
	}
	return string(res.([]byte)), err
}

func (r *Redis) Set(key string, val interface{}) error {
	_, err := r.conn.Do("set", key, val)
	return err
}

func (r *Redis) SetEx(key string, val interface{}, ts time.Duration) error {
	_, err := r.conn.Do("set", key, val, "EX", ts.Seconds())
	return err
}

func (r *Redis) SetExAt(key string, val interface{}, expire time.Time) error {
	_, err := r.conn.Do("set", key, val, "EXAT", expire.Unix())
	return err
}
